import { App } from "vue";
import { useUserStore } from "@/store/user";

export const regPermission = (app: App<Element>) => {
  app.directive("permission", {
    // 某个生命周期里面判断当前 userStore 里面是否有 传入的 value
    mounted(el, binding) {
      const store = useUserStore();
      //   binding.value  传进来的值
      //   判断数组中有无传入的值，有就留着，没有就删除
      if (!store.Permissions.includes(binding.value)) {
        //   删除真实DOM
        el.remove();
      }
    },
  });
};
